T
CSharpTest.Net
LListNode<T> Class
Members  Example  See Also  Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LListNode<T> Class

Glossary Item Box

A typed node, used similiarly to LinkedListNode<T>. Can belong to single list at a time, the type of list is usually LListNode<T>.LList

Syntax

Visual Basic (Declaration) 
Public Class LListNode(Of T) 
   Inherits LListNode
C# 
public class LListNode<T> : LListNode 

Type Parameters

T

Example

Library/Library.Test/TestLinkList.cs

C#Copy Code
LListNode<string> empty = new LListNode<string>();
LListNode<string> valueA = new LListNode<string>("A");
LListNode<string> valueB = new LListNode<string>("B");
LListNode<string>.LList list = new LListNode<string>.LList();

list.AddFirst(empty);
Assert.AreEqual(1, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(empty, list.Last);
Assert.IsNull(empty.Next);
Assert.IsNull(empty.Previous);

list.AddLast(valueB);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(empty, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.IsNull(empty.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.AddFirst(valueA);
Assert.AreEqual(3, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, empty.Next);
Assert.AreEqual(valueA, empty.Previous);

Assert.AreEqual(empty, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(empty, valueB.Previous);
Assert.IsNull(valueB.Next);

list.Remove(empty);
Assert.AreEqual(2, list.Count);
Assert.AreEqual(valueA, list.First);
Assert.AreEqual(valueB, list.Last);

Assert.AreEqual(valueB, valueA.Next);
Assert.IsNull(valueA.Previous);

Assert.AreEqual(valueA, valueB.Previous);
Assert.IsNull(valueB.Next);
VB.NETCopy Code
Dim empty As New LListNode(Of String)()
Dim valueA As New LListNode(Of String)("A")
Dim valueB As New LListNode(Of String)("B")
Dim list As New LListNode(Of String).LList()

list.AddFirst(empty)
Assert.AreEqual(1, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(empty, list.Last)
Assert.IsNull(empty.[Next])
Assert.IsNull(empty.Previous)

list.AddLast(valueB)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(empty, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.IsNull(empty.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.AddFirst(valueA)
Assert.AreEqual(3, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, empty.[Next])
Assert.AreEqual(valueA, empty.Previous)

Assert.AreEqual(empty, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(empty, valueB.Previous)
Assert.IsNull(valueB.[Next])

list.Remove(empty)
Assert.AreEqual(2, list.Count)
Assert.AreEqual(valueA, list.First)
Assert.AreEqual(valueB, list.Last)

Assert.AreEqual(valueB, valueA.[Next])
Assert.IsNull(valueA.Previous)

Assert.AreEqual(valueA, valueB.Previous)
Assert.IsNull(valueB.[Next])

Inheritance Hierarchy

System.Object
   CSharpTest.Net.Collections.LListNode
      CSharpTest.Net.Collections.LListNode<T>

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys